static int domain_create_ring(struct domain *dom)
{
- char *dompath, *path;
+ char *dompath;
int err;
- asprintf(&path, "/console/%d/domain", dom->domid);
- dompath = xs_read(xs, path, NULL);
- free(path);
+ dompath = xs_get_domain_path(xs, dom->domid);
if (!dompath)
return ENOENT;
if (dom && (dom->evtchn_fd == -1 || dom->page == NULL))
domain_create_ring(dom);
}
+ enum_domains();
xs_acknowledge_watch(xs, vec[1]);
free(vec);
goto out_close_data;
}
- if (!xs_watch(xs, "/console", "console")) {
- dolog(LOG_ERR, "xenstore watch on /console fails.");
+ if (!xs_watch(xs, "@introduceDomain", "console")) {
+ dolog(LOG_ERR, "xenstore watch on @introduceDomain fails.");
goto out_close_data;
}
return false;
}
+bool check_event_node(const char *node)
+{
+ if (!node || !strstarts(node, "@")) {
+ errno = EINVAL;
+ return false;
+ }
+ return true;
+}
+
static void send_directory(struct connection *conn, const char *node)
{
char *path, *reply;
bool check_node_perms(struct connection *conn, const char *node,
enum xs_perm_type perm);
+/* Check if node is an event node. */
+bool check_event_node(const char *node);
+
/* Path to this node outside transaction. */
char *node_dir_outside_transaction(const char *node);
#include "talloc.h"
#include "xenstored_core.h"
#include "xenstored_domain.h"
+#include "xenstored_watch.h"
#include "xenstored_test.h"
static int *xc_handle;
/* Now domain belongs to its connection. */
talloc_steal(domain->conn, domain);
+
+ fire_watches(conn, "@introduceDomain", false);
+
send_ack(conn, XS_INTRODUCE);
}
/* Check read permission: no permission, no watch event.
* If it doesn't exist, we need permission to read parent.
*/
- if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK)) {
+ if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK) &&
+ !check_event_node(node)) {
fprintf(stderr, "No permission for %s\n", node);
return;
}
return;
}
- relative = !strstarts(vec[0], "/");
- vec[0] = canonicalize(conn, vec[0]);
- if (!is_valid_nodename(vec[0])) {
- send_error(conn, errno);
- return;
+ if (strstarts(vec[0], "@")) {
+ relative = false;
+ /* check if valid event */
+ } else {
+ relative = !strstarts(vec[0], "/");
+ vec[0] = canonicalize(conn, vec[0]);
+ if (!is_valid_nodename(vec[0])) {
+ send_error(conn, errno);
+ return;
+ }
}
watch = talloc(conn, struct watch);